export default (target) => {
  /**
   * 模板字符串替换
   * @param {*} template
   * @param {*} replaceObject
   * @returns
   */
  target.tplReplace = (template, replaceObject) => {
    return template().replace(/{{(.*?)}}/g, (node, key) => {
      return replaceObject[key]
    })
  }

  target.createElement = (elem, inner) => {
    const oElem = document.createElement(elem)
    oElem.innerHTML = inner
    return oElem
  }

  /**
   * 找到目标元素
   * @param {*} ev 
   * @returns 
   */
  target.getTarget = (ev) => {
    const e = ev || window.event 
    return e.target || e.srcElement
  }
}
